package org.jeecg.modules.xl.h5api.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.annotation.Export2Swagger;
import org.jeecg.modules.xl.h5api.service.IH5APIService;
import org.jeecg.modules.xl.h5api.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 门店端API
 *
 * @author deco
 * @create 2024-11-21
 */
@Api(tags="小程序退货单接口")
@RestController
@RequestMapping("/slt/h5api")
@Slf4j
public class H5APIController {
    @Autowired
    private IH5APIService ih5APIService;
    @ApiOperation(value = "售后单-门店选择接口", notes = "售后单-门店选择接口")
    @GetMapping(value = "/getMyStore")
    public Result<List<MyStoreVO>> getMyStoreByToken(){
        return Result.OK(ih5APIService.getMyStore());
    }
    @ApiOperation(value = "门店数据", notes = "门店数据")
    @GetMapping(value = "/getMyStoreData")
    public Result<List<MyStoreDataVO>> getMyStoreDataByToken(){
        return Result.OK(ih5APIService.getMyStoreData());
    }


    @ApiOperation(value = "查询快递单详情", notes = "查询快递单详情")
    @GetMapping(value = "/getLogiOrderDetail")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "LogiOrder", value = "快递单编码", required = true, paramType = "query", dataType = "String")
    })
    public Result<List<LogiOrderDetail>> getLogiOrderDetail(@RequestParam(name = "LogiOrder", required = true) String LogiOrder) {
        return Result.OK(ih5APIService.getLogiOrderDetail(LogiOrder));
    }


    @ApiOperation(value = "新增售后单", notes = "新增售后单")
    @PostMapping(value = "/addAfterSaltOrder")
    public Result<String> addAfterSaltOrder(@RequestBody AfterSaltOrderAddVo afterSaltOrderAddVo){
        ih5APIService.addAfterSaltOrder(afterSaltOrderAddVo);
        return Result.OK("添加成功！");
    }

    @ApiOperation(value = "删除售后单", notes = "删除售后单")
    @GetMapping(value = "/deleteAfterSaltOrder")
    public Result<String> deleteAfterSaltOrder(@RequestParam(name = "workorder", required = true) String workorder){
        return  ih5APIService.deleteAfterSaltOrder(workorder);
    }



    @ApiOperation(value = "获取售后单列表", notes = "获取售后单列表")
    @GetMapping(value = "/getAfterOrderList")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "storeCode", value = "门店编码", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "woStatus", value = "售后单状态", required = true, paramType = "query", dataType = "String")
    })
    public Result<List<AfterSaltOrderVO> > getAfterOrderList(@RequestParam(name = "storeCode", required = true) String storeCode, @RequestParam(name = "woStatus", required = true) String woStatus) {

        return Result.OK(ih5APIService.getAfterOrderList(storeCode,woStatus));
    }

    @ApiOperation(value = "获取售后单列表", notes = "获取售后单列表")
    @GetMapping(value = "/getAfterOrderListByToken")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "woStatus", value = "售后单状态", required = true, paramType = "query", dataType = "String")
    })
    public Result< List<AfterSaltOrderVO> > getAfterOrderListByToken( @RequestParam(name = "woStatus", required = true) String woStatus) {
        return Result.OK(ih5APIService.getAfterOrderListByToken(woStatus));
    }
    
    @ApiOperation(value = "获取售后单详情", notes = "获取售后单详情")
    @GetMapping(value = "/getAfterOrderDetail")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "workorder", value = "售后单号", required = true, paramType = "query", dataType = "String")
    })
    public Result<ASOrderVO> getAfterOrderDetail(@RequestParam(name = "workorder", required = true) String workorder) {
        return Result.OK(ih5APIService.getAfterOrderDetail(workorder));
    }


    @ApiOperation(value = "获取工作台菜单", notes = "获取工作台菜单")
    @GetMapping(value = "/getMenuList")
    public Result<List<MenuDTO> > getMenuList() {

        return Result.OK(ih5APIService.getMenuList());
    }
}
